package com.hcbd.tdwt.ui.setting.hlct;

import android.annotation.SuppressLint;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.core.content.ContextCompat;


import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.Constant;
import com.hcbd.tdwt.ui.common.dialog.BottomSelectDialog;
import com.hcbd.tdwt.util.SharedPreferencesUtil;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.util.Arrays;
import java.util.List;

@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_audio_setting_tt)
public class AudioSettingActivity extends BaseActivity {
    @ViewById
    TextView title;
    @ViewById
    ImageButton headLeft;
    @ViewById
    TextView roteTv;
    private SharedPreferencesUtil sp;
    private BottomSelectDialog bottomSelectDialog;
    private String rateStr[] = {"2400", "1200", "700", "450"};

    @AfterViews
    protected void init() {
        sp = new SharedPreferencesUtil(this);
        title.setText("语音设置");
        title.setTextColor(ContextCompat.getColor(this,R.color.black));
        headLeft.setBackground(ContextCompat.getDrawable(this,R.drawable.left_arrow));
        setAndroidNativeLightStatusBar(true);
        int currentIndex = sp.getAttributeInt(Constant.ENCODER_RATE);
        roteTv.setText(rateStr[currentIndex]);
        List<String> str = Arrays.asList(rateStr);
        bottomSelectDialog = new BottomSelectDialog(this, "选择语音压缩率", str, (index, str1) -> {
            sp.addAttribute(Constant.ENCODER_RATE, index);
            Constant.encoderCodeRate = index;
            roteTv.setText(str1);
        });
    }

    @Click
    void speechZip() {
        BottomSelectDialog.show(bottomSelectDialog);
    }

    @Click
    void headLeft() {
        finish();
    }
}
